<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单下账</title>
    <link rel="shortcut icon" href="favicon.ico">
    <script src="../../res/js/comm.js?v=1.22.0"></script>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="panel panel-info">
            <div class="panel-heading"><i class="fa fa-info-circle"></i> 下账列表</div>
            <div class="panel-body">
                <div class="ibox-query">
                    <form id="queryForm" method="post" class="form-horizontal">
                        <input name="billStatus" type="hidden">
                        <div class="form-group">

                            <label class="col-sm-1 control-label">顶级渠道</label>
                            <div class="col-sm-2" style="display: flex">
                                <select id="topChannelCode" name="topChannelCode" style="width: 100%;" class="form-control" onchange="changeToChannelCode(this.value)"></select>
                                <label id="top_channel_tips"></label>
                            </div>
                            <label class="col-sm-1 control-label">订单编码</label>
                            <div class="col-sm-2"><input name="orderCode" class="form-control" type="text"></div>

                            <label class="col-sm-1 control-label">三方订单号</label>
                            <div class="col-sm-2"><input name="outTradeCode" class="form-control" type="text"></div>

                            <label class="col-sm-1 control-label">POS编码</label>
                            <div class="col-sm-2"><input name="posCode" class="form-control" type="text"></div>

                        </div>

                        <div class="form-group">
                            <label class="col-sm-1 control-label">账单类型</label>
                            <div class="col-sm-2">
                                <select name="billType" class="form-control" onchange="javascript:$.openx.query()">
                                    <option value="">--请选择--</option>
                                    <option value="SALE">销售单</option>
                                    <option value="REFUND">退货单</option>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label">子渠道</label>
                            <div class="col-sm-2" style="display: flex">
                                <input id="channelCode" disabled name="channelCode" class="form-control" type="text" value="0个选中项">
                            </div>
							<input type="hidden" name="storeCodes" id="storeCodes">

                            <label class="col-sm-1 control-label">下账开始时间</label>
                            <div class="col-sm-2"><input class="layui-input" id='createStartTime' name="createStartTime" placeholder="下单开始时间" type="text"
                                    readonly onclick="layui.laydate({elem: this, istime: true,isclear:false, format: 'YYYY-MM-DD hh:mm:ss'})">                                </div>

                            <label class="col-sm-1 control-label">下账结束时间</label>
                            <div class="col-sm-2"><input class="layui-input" id='createEndTime' name="createEndTime" placeholder="下单结束时间" type="text"
                                    readonly onclick="layui.laydate({elem: this,isclear:false, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">                                </div>

                        </div>

                        <!-- add by zhouwk -->
                        <div class="form-group">
                            <label class="col-sm-1 control-label">门店编码：</label>
                            <div class="col-sm-2"><input name="warehouseCode" class="form-control" type="text"></div>
                        </div>
                        <!-- add by zhouwk end -->

                        <div class="form-group">
                            <div>
                                <button style="margin-left: 100px;" class="btn btn-info" onclick='$.openx.query()' type="button"><i class="glyphicon glyphicon-search"></i> 查询</button>

                                <button style="margin-left: 10px;" class="btn btn-info" onclick="resetForm()" type="button"><i class="glyphicon glyphicon-share-alt"></i> 重置  </button>
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                    </form>
                </div>

                <div class="row row-lg">
                    <div class="col-sm-12">
                        <div class="bars pull-left">
                            <p>
                                <button type="button" name="billStatus" value="" class="btn btn-sm btn-info"><i  class="glyphicon glyphicon-ok-sign"></i> <small>全部</small></button>
                                <button type="button" name="billStatus" value="SUCCESS" class="btn btn-sm btn-primary"><i></i> 成功</button>
                                <button type="button" name="billStatus" value="FAILED" class="btn btn-sm btn-danger"><i></i> 失败 </button>


                            </p>
                        </div>
                        <table id="table" data-show-export="true">
                            <thead>
                                <tr>
                                    <!-- <th data-field="stats" data-checkbox="true"></th> -->
                                    <th data-align="center" data-field="id" data-formatter="$.openx.generatorId" data-width="50px"> 序号</th>
                                    <th data-align="center" data-formatter="operationFormat" data-width="150px">操作</th>
                                    <th data-align="center" data-field="orderCode" data-width="225px">订单号</th>
                                    <th data-align="center" data-field="outTradeCode" data-formatter="formatCode">三方订单号</th>
                                    <th data-align="center" data-field="posCode" data-formatter="formatCode" >pos编码</th>
                                    <th data-align="center" data-field="billTypeName">账单类型</th>
                                    <th data-align="center" data-field="storeCode">门店编码</th>
                                    <th data-align="center" data-field="needReceiveAmount">订单金额</th>
                                    <th data-align="center" data-field="statusName">下账状态</th>
                                    <th data-align="center" data-field="topChannelCode"  data-visible="false">渠道</th>
                                    <th data-align="center" data-field="topChannelName">渠道</th>
                                    <th data-align="center" data-field="createTime" data-formatter="createTimeFormat">下账时间</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--下账模版 start-->
    <script type="text/html" id="postingTpl">
        <div style="padding: 10px">
            <table class="layui-table">
                <tbody>
                    <tr>
                        <td class="layui-table-td-bg">小票序号:</td>
                        <td class="text-center"> {{d.ticketNum ? d.ticketNum :"" }} </td>
                        <td class="layui-table-td-bg">收货人:</td>
                        <td class="text-center">{{d.receiverName ? d.receiverName :"" }}</td>

                    </tr>
                    <tr>
                        <td class="layui-table-td-bg">订单编码:</td>
                        <td class="text-center"> {{d.orderCode ? d.orderCode :"" }} </td>
                        <td class="layui-table-td-bg">收货电话:</td>
                        <td class="text-center">{{d.receiverPhone ? d.receiverPhone :"" }}</td>

                    </tr>
                    <tr>
                        <td class="layui-table-td-bg">营业员工号:</td>
                        <td class="text-center">
                            <select data-placeholder="请选择下账员工..." class="form-control" style="width:100%;text-align: center" tabindex="2" name="" id="storeUserSelect">

                            {{#  layui.each(d.salesCodes, function(index, item){ }}
                                <option value={{item}} style="text-align: center">{{item}}</option>
                            {{# }); }}
                    </select>
                        </td>
                    </tr>
                    <table id="goodsInfo" class="layui-table" style="text-align: center;margin: 0px">
                        <thead>
                            <tr>
                                <th data-align="center" style="text-align: center" data-field="goodsCode" data-width="225px">商品编码</th>
                                <th data-align="center" style="text-align: center" data-field="goodsName">商品名称</th>
                                <th data-align="center" style="text-align: center" data-field="goodsAmount">商品数量</th>
                                <th data-align="center" style="text-align: center" data-field="lotNum">批次号</th>
                                <th data-align="center" style="text-align: center" data-field="amount">数量</th>
                                <th data-align="center" style="text-align: center" data-field="insertOrDelete">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{# layui.each(d.lotInfoList, function(index, item){ }}
                            <tr>
                                <td>{{item.goodsCode }}</td>
                                <td>{{item.goodsName}}</td>
                                <td>{{item.goodsAmount}}</td>
                                <td>
                                    {{# if(item.lotNum.length>0){ }}
                                    <select style="width:100%" name="lotNumSelect" class="form-control">
                                {{#  layui.each(item.lotNum, function(index, item){ }}
                                <option value = {{item}}>
                                        {{item}}
                                </option>
                                {{# }); }}
                            </select> {{# } }} {{# if(item.lotNum.length==0){ }}
                                    <select style="width:100%" name="lotNumSelect" class="form-control">
                                <option value = ''>
                                        --无批次信息--
                                </option>
                            </select> {{# } }}
                                </td>
                                <td>
                                    {{# if(item.lotNum.length>0){ }}
                                    <select style="width:100%" name="amountSelect" class="form-control">
                                {{#  layui.each(item.amount, function(index, item){ }}
                                <option value = {{item}}>
                                        {{item}}
                                </option>
                                {{# }); }}
                            </select> {{# } }} {{# if(item.lotNum.length==0){ }}
                                    <select style="width:100%" name="amountSelect" class="form-control">
                                <option value = {{item}}>
                                        --请选择--
                                </option>
                            </select> {{# } }}
                                </td>
                                <td>
                                    <button type="button" class="btn btn-outline btn-success btn-xs" onclick="javascript:addRowsData(this,this.parentNode.parentNode)">新增</button>
                                    <button type="button" class="btn btn-outline btn-default btn-xs" disabled="disabled" onclick="javascript:deleteRowsData(this.parentNode.parentNode)">删除</button>
                                </td>
                            </tr>
                            {{# }); }}
                            </thead>
                    </table>

                    <br/>
                    <div class="form-group">
                        <div class="col-sm-4">

                        </div>
                        <div class="col-sm-2">
                            <button type="button" class="btn btn-success" onclick="submitKeepAccount()"> 确定</button>
                        </div>
                        <div class="col-sm-2">
                            <button type="button" class="btn btn-default" onclick="javascript:layer.closeAll()"> 取消</button>
                        </div>
                        <div class="col-sm-4"></div>
                    </div>
                    <br/><br/><br/>
                    </tbody>
            </table>
        </div>
    </script>
</body>
<script type="text/javascript">
    (function () {
        $.openx.loadScript(['../../js/order/posting.js']);
    })();

</script>
<script src="../../res/plugins/channel/yfTopChannel.js"></script>
<link href="../../res/plugins/channel/css/yfChannel.css" rel="stylesheet">
</html>
